<p>
<?php

$record = $this->record;
$records = $this->records;

if (isset($this->messages)) {
	foreach ($this->messages as $field => $messages) {
		foreach ($messages as $message) {
			echo $this->escape($message) . "<br />\n";
		}
	}	
}

if (isset($_POST['btnSave'])) {
	foreach($_POST as $key=>$item) {
		$record[$key] = $item;
	}
}
?>
<a href="<?php echo $this->baseUrl; ?>/admin/role">Lists</a>
<form action="<?php echo $this->baseUrl ?>/admin/role/privilege/id/<?php echo $record['id']; ?>" method="POST">

<?php
if (isset($record['parent'])) {
	echo '<h3>Parent Name: ' . strtoupper($record['parent']['name']) . '</h3>';
}

echo '<h3>Role Name: ' . strtoupper($record['name']) . '</h3>';

if (isset($record['super_user']) && $record['super_user']) {
	echo '<h3>' . strtoupper($record['name']) . ' is Super User</h3>';
}
if (isset($records) && $records) {
	foreach ($records as $record) {
		foreach ($record['resources'] as $resource) {
?>
<b><?php echo $record['name']; ?></b>
<table cellpadding="2" cellspacing="2" border="1">
			<?php
			foreach ($resource['privileges'] as $key=>$privilege) {
				$checked = '';
				if (isset($this->aclList[$key])) {
					$checked = 'checked="checked"';
				}
			?>
	<tr>		
		<td><?php echo $privilege['name']; ?></td>
		<td><input type="checkbox" name="" <?php echo $checked; ?> /></td>
	</tr>
	<?php
			}
	?>
</table><br />
<?php
		}
	}
?>
	<input type="submit" name="btnSubmit" value="Submit">
	<input type="submit" name="btnCancel" value="Cancel">
<?php
} else {
	echo "No defined resources!";
}
?>

</form>
</p>
